package com.acwing.partition3;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/5/1 10:34
 */
public class AC256最大异或和 {

    private static final int N = 600010, M = N * 24;
    //maxVer[i]记录trie树节点对应的子树中最大版本号
    private static int[] maxVer = new int[M], s = new int[N], root = new int[N];
    private static int[][] tr = new int[M][2];
    private static int n, m, idx = 0;

    private static StreamTokenizer tokenizer = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    private static PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        n = nextInt(); m = nextInt();
        root[0] = ++idx;
        maxVer[0] = -1;
        insert(0, 0, root[0]);
        for (int i = 1; i <= n; i++) {
            int x = nextInt();
            root[i] = ++idx;
            s[i] = s[i - 1] ^ x;
            insert(i, root[i - 1], root[i]);
        }
        for (int i = 0; i < m; i++) {
            char op = next().charAt(0);
            int l, r, x;
            if (op == 'A') {
                x = nextInt();
                n++;
                s[n] = s[n - 1] ^ x;
                root[n] = ++idx;
                insert(n, root[n - 1], root[n]);
            } else {
                l = nextInt(); r = nextInt(); x = nextInt();
                writer.println(query(root[r - 1], l - 1, s[n] ^ x));
            }
        }
        writer.flush();
    }

    private static void insert(int k, int p, int q) {
        maxVer[q] = k;
        for (int i = 23; i >= 0; i--) {
            int v = s[k] >> i & 1;
            //如果存在上一个版本，就把上一个版本非当前路径的结点复制过来
            if (p != 0) tr[q][v ^ 1] = tr[p][v ^ 1];
            tr[q][v] = ++idx;
            maxVer[tr[q][v]] = k;
            q = tr[q][v];
            p = tr[p][v];
        }
    }

    private static int query(int root, int l, int c) {
        int p = root;
        for (int i = 23; i >= 0; i--) {
            //从高到低取出当前值的每一位二进制位
            int v = c >> i & 1;
            //贪心，版本合法的情况下，尽量选择和当前二进制位不同的一个节点，这样才能使结果尽量大；自带判空功能如果没有点, max_id会为0, 那就肯定不能满足>=l
            if (maxVer[tr[p][v ^ 1]] >= l) p = tr[p][v ^ 1];
            else p = tr[p][v];
        }
        return c ^ s[maxVer[p]];
    }

    private static int nextInt() throws IOException {
        tokenizer.nextToken();
        return (int) tokenizer.nval;
    }

    private static String next() throws IOException {
        tokenizer.nextToken();
        return tokenizer.sval;
    }
}
